#include "Utils.h"
#include "iconv/iconv.h"

Utils::Utils(void)
{
}


Utils::~Utils(void)
{
}

QString Utils::ConvertFromLocal8Bit(const char* strValue)
{
	QString qstrValue;
#ifdef Q_OS_WIN
	qstrValue = QString::fromLocal8Bit(strValue);
#else
	qstrValue = strValue;
#endif
	return qstrValue;
}

void Utils::Gb2312ToUTF8(char *szOut, const char *szIn)
{
	char * pszIn = (char *)szIn;	
	char * pszOut = (char *)szOut;	
	size_t nIn = strlen(szIn);	
	size_t nOut = 1024;	

	iconv_t type = iconv_open("UTF-8", "GB2312");
	iconv(type, (const char **)&pszIn, &nIn, (char **)&pszOut, &nOut);
	iconv_close(type);

	szOut[1024-nOut]=0;	
}
